import requests
from common.get_header_tools import get_req_header
class EmpManagerApi():
    @staticmethod
    def emp_add(req_header, req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=req_header, json=req_body)
        return resp
    @staticmethod
    def emp_query(emp_id, req_header):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header)
        return resp
    @staticmethod
    def emp_put(emp_id, req_header, req_body, ):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header, json=req_body)
        return resp
    @staticmethod
    def emp_delete(emp_id, req_header):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header)
        return resp


# 必须自测
if __name__ == "__main__":
    # 准备请求头
    req_header = get_req_header()
    # 准备请求体
    req_body = {"username": "user87655430",
                "mobile": "13947884786",
                "workNumber": "9527890aa"}
    # 调用静态方法
    resp = EmpManagerApi.emp_add(req_header,req_body)
    print("添加员工:",resp.json())